package com.zcf.service;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zcf.common.json.Body;
import com.zcf.mapper.PlayBackMapper;
import com.zcf.pojo.PlayBack;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author ZhaoQi
 * @since 2019-03-18
 */
@Service
public class PlayBackServiceImpl  {

	@Autowired
	PlayBackMapper pb;
	
	public Object getplayback(PlayBack back) {
		EntityWrapper<PlayBack> w = new EntityWrapper<PlayBack>();
		w.eq("backNum", back.getBackNum());
		PlayBack back2 = back.selectOne(w);
		System.out.println(back2.getBackContent().toString());
		return JSON.parse(back2.getBackContent().toString()) ;
	}

	public Body getplaynum(PlayBack back) {
		List<Map<String, Object>> lists = new ArrayList<Map<String,Object>>();
		if(back.getRoomName()!=null){
			Map<String, Object> map = new HashMap<String, Object>();
			
			List<PlayBack> list = back.selectList(new EntityWrapper<PlayBack>().eq("roomName", back.getRoomName()));
			for (PlayBack playBack : list) {
				map = new HashMap<String, Object>();
				map.put("backnum", playBack.getBackNum());
				lists.add(map);
			}
		}
		return Body.newInstance(lists);
	}
	

	
}
